package com.action;

import com.controller.GetResultList;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by lirance on 16/5/17.
 */
public class getResultsBylmd extends BaseAction {
    int k;
    int clustNum;
    int Gn;

    List<Double> mae;
    List<Double> rmse;


    public int getK() {
        return k;
    }

    public void setK(int k) {
        this.k = k;
    }

    public int getClustNum() {
        return clustNum;
    }

    public void setClustNum(int clustNum) {
        this.clustNum = clustNum;
    }

    public int getGn() {
        return Gn;
    }

    public void setGn(int gn) {
        Gn = gn;
    }

    public List<Double> getMae() {
        return mae;
    }

    public void setMae(List<Double> mae) {
        this.mae = mae;
    }

    public List<Double> getRmse() {
        return rmse;
    }

    public void setRmse(List<Double> rmse) {
        this.rmse = rmse;
    }

    @Override
    public String execute() throws Exception {
        this.setMae(new ArrayList<>());
        this.setRmse(new ArrayList<>());
        DecimalFormat df = new DecimalFormat("0.0");
        if (k != 0) {
            for (double i = 0.0; i <= 1.0; i += 0.1) {
              /*  List<Double> l = new GetMaeRmse().GetMaeRmse(i, k, clustNum,30);*/

                List<Double> l=new GetResultList().GetResult(k,Gn, Double.parseDouble(df.format(i)),clustNum);
                mae.add(l.get(0));
                rmse.add(l.get(1));
            }
        }
        return SUCCESS;
    }
}
